home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / elk-2_0.lha / elk-2.0 / lib / xt / identifier.c < prev    next >
C/C++ Source or Header  |  1992-10-09  |  1KB  |  41 lines

  1.  
  2. #include "xt.h"
  3.  
  4. Generic_Predicate (Identifier)
  5.  
  6. static Identifier_Equal (x, y) Object x, y; {
  7.     register struct S_Identifier *p = IDENTIFIER(x), *q = IDENTIFIER(y);
  8.     return p->type == q->type && p->val == q->val && !p->free && !q->free;
  9. }
  10.  
  11. Generic_Print (Identifier, "#[identifier %u]", POINTER(x))
  12.  
  13. Object Make_Id (type, val, num) XtPointer val; {
  14.     Object i;
  15.  
  16.     i = Find_Object (T_Identifier, (GENERIC)0, Match_Xt_Obj, type, val);
  17.     if (Nullp (i)) {
  18.     i = Alloc_Object (sizeof (struct S_Identifier), T_Identifier, 0);
  19.     IDENTIFIER(i)->tag = Null;
  20.     IDENTIFIER(i)->type = type;
  21.     IDENTIFIER(i)->val = val;
  22.     IDENTIFIER(i)->num = num;
  23.     IDENTIFIER(i)->free = 0;
  24.     Register_Object (i, (GENERIC)0, (PFO)0, 0);
  25.     }
  26.     return i;
  27. }
  28.  
  29. XtPointer Use_Id (x, type) Object x; {
  30.     Check_Type (x, T_Identifier);
  31.     if (IDENTIFIER(x)->type != type || IDENTIFIER(x)->free)
  32.     Primitive_Error ("invalid identifier");
  33.     IDENTIFIER(x)->free = 1;
  34.     Deregister_Object (x);
  35.     return IDENTIFIER(x)->val;
  36. }
  37.  
  38. init_xt_identifier () {
  39.     Generic_Define (Identifier, "identifier", "identifier?");
  40. }
  41.